package day0520;

import java.util.Arrays;
import java.util.Scanner;

public class Test7 {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        System.out.println("请输入起始年份和结束年份");
        int sY=s.nextInt();
        int eY=s.nextInt();
        if(sY>eY){
            int t=sY;
            sY=eY;
            eY=t;
        }
        int[] a=getYears(sY,eY);
        System.out.println(Arrays.toString(a));
    }

    public static int[] getYears(int startYear, int endYear) {
        //打印2000到2025之间的，第一个闰年
        int[]  a={};
        for (int i = startYear;   i<=endYear   ; i++) {
            if( (i%400==0  || (i%4==0 && i%100!=0))){
              a= Arrays.copyOf(a,   a.length+1);//将i放入到a数组
              a[a.length-1]=i;
            }
        }
        return a;//返回结果
    }
}
